]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
popupMenu: Disconnect signal handlers when child section is destroyed
authorSebastian Keller <skeller@gnome.org>
Thu, 10 Sep 2026 22:13:24 +0000 (00:13 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sun, 13 Sep 2026 21:56:15 +0000 (23:56 +0200)
Neither `PopupMenuBase` nor `PopupMenuSection` are destroyable, thus the
signal connection needs to be manually disconnected to avoid leaking
both via the respective signal trackers.

This disconnects the connections in both directions when the child
`PopupMenuSection` is destroyed, which handles both cases the section
being destroyed, but also the parent menu being destroyed, because that
also triggers the destruction of all children.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4398>
(cherry picked from commit 2a923660bc1212cc0249dbb8833d28a708f089c0)

js/ui/popupMenu.js

index 463ecb28fd781004983f5760f3661349467d4d81..7dce5b66138e0389361ef9af18450f9c9dff32df 100644 (file)
@@ -879,7 +879,11 @@ export class PopupMenuBase extends Signals.EventEmitter {
         if (menuItem instanceof PopupMenuSection) {
             menuItem.connectObject(
                 'active-changed', this._subMenuActiveChanged.bind(this),
-                'destroy', () => this.length--, this);
+                'destroy', () => {
+                    this.length--;
+                    this.disconnectObject(menuItem);
+                    menuItem.disconnectObject(this);
+                }, this);
 
             this.connectObject(
                 'open-state-changed', (self, open) => {